﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PKURG.CostSplit.Business;

public partial class Admin_UserConfig_ManagerUser :PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected override bool CheckPermission()
    {
        return Permission.GetManagerPermission();
    }

    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (lb_RelationList.SelectedItem == null || lb_NoHaveBeRelationList.SelectedItem == null)
        {
            return;
        }
        string eId = lb_RelationList.SelectedItem.Value;
        string mId = lb_NoHaveBeRelationList.SelectedItem.Value;

        PKURG.CostSplit.Business.Sys_Admin.Relation(eId, mId);
        Refresh();
    }
    protected void btnDel_Click(object sender, EventArgs e)
    {
        if (lb_RelationList.SelectedItem == null || lb_HaveBeRelationList.SelectedItem == null)
        {
            return;
        }
        string eId = lb_RelationList.SelectedItem.Value;
        string mId = lb_HaveBeRelationList.SelectedItem.Value;

        PKURG.CostSplit.Business.Sys_Admin.UnRelation(eId, mId);
        Refresh();
    }

    protected void lb_RelationList_SelectedIndexChanged(object sender, EventArgs e)
    {
        dynamic info = Sys_Admin.GetUserInfo(lb_RelationList.SelectedItem.Value);
        if (info.PType=="0")
        {
            btnAdd.Enabled = false;
            btnDel.Enabled = false;
        }
        else
        {
            btnAdd.Enabled = true;
            btnDel.Enabled = true;
        }

        Refresh();
    }

    private void Refresh()
    {
        lb_NoHaveBeRelationList.DataBind();
        lb_HaveBeRelationList.DataBind();
    }
    protected void tbUser_TextChanged(object sender, EventArgs e)
    {
        lb_RelationList.DataBind();
    }
}